package com.syy.controller.admin.task.vo.instance;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.syy.common.core.domain.KeyValue;
import com.syy.controller.admin.base.user.UserSimpleBaseVO;
import com.syy.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Schema(description = "管理后台 - 流程实例的 Response VO")
@Data
@Accessors(chain = true)
public class BpmProcessInstanceRespVO {

    private String id;

    private String name;

    @Schema(description = "流程摘要")
    private List<KeyValue<String, String>> summary; // 只有流程表单，才有摘要！

    private String category;

    private String categoryName;

    private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举

    private LocalDateTime startTime;

    private LocalDateTime endTime;

    @Schema(description = "持续时间", example = "1000")
    private Long durationInMillis;

    private Map<String, Object> formVariables;

    @Schema(description = "业务的唯一标识-例如说，请假申请的编号", example = "1")
    private String businessKey;

    /**
     * 发起流程的用户
     */
    private UserSimpleBaseVO startUser;

    private String processDefinitionId;
    /**
     * 流程定义
     */
    private BpmProcessDefinitionRespVO processDefinition;

    /**
     * 当前审批中的任务
     */
    private List<Task> tasks; // 仅在流程实例分页才返回

    @Schema(description = "流程任务")
    @Data
    public static class Task {

        private String id;

        private String name;

        @JsonIgnore // 不返回，只是方便后续读取，赋值给 assigneeUser
        private Long assignee;

        private UserSimpleBaseVO assigneeUser;

    }

}
